// import { baseCompile } from '@vue/compiler-core'
import axios from 'axios'
// baseURl 超时时间配置
const instance =axios.create({
  baseURL: 'http://pcapi-xiaotuxian-front-devtest.itheima.net',
  timeout: 5000
})
// 全局注入token
// 请求拦截器
instance.interceptors.request.use(config=>{
  return config
},
e=>Promise.reject)
// 响应拦截器
instance.interceptors.response.use((response)=>{
  return response
},e=>Promise.reject)

const request=(url,method,submitData)=>{
  return instance({
    url,method,
    [method.toLowerCase()==='get'?'params':data]:submitData
  })
}
export default request